﻿using Rafy.Book.Views;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Navigation.Regions;
using Rafy.Domain;
using Rafy.Book.ViewModels;

namespace Rafy.Book
{
    public class BookModule: IModule
    {
        public void OnInitialized(IContainerProvider containerProvider)
        {
            var regionManager = containerProvider.Resolve<IRegionManager>();
           
            //**这里是系统加载后默认打开的视图页***

            //方法1  向ContentRegion控件中注入BookPage视图
            //在MainWindows页面中，默认打开BookPage页面
            regionManager.RegisterViewWithRegion("ContentRegion", typeof(PracticePage));
            //在bookpage页面中，默认打开MathPage页面
            regionManager.RegisterViewWithRegion("TempContentRegion", typeof(MathPage));

            //方法2 这里用视图注入
            //var region = regionManager.Regions["ContentRegion"];
            //region.RequestNavigate("BookPage");
        }
        //注册导航
        public void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterForNavigation<BookPage>();
            containerRegistry.RegisterForNavigation<MathPage>();
            containerRegistry.RegisterForNavigation<ChinesePage>();
            containerRegistry.RegisterForNavigation<EnglishPage>();
            containerRegistry.RegisterForNavigation<ListingsPage>();
            containerRegistry.RegisterForNavigation<ConfigPage>();
            containerRegistry.RegisterForNavigation<ZiciPage>();
            containerRegistry.RegisterForNavigation<PracticePage>();


            containerRegistry.RegisterDialog<FmSubject, FmSubjectViewModel>();
            containerRegistry.RegisterDialog<FmKeMu, FmKeMuViewModel>();
            containerRegistry.RegisterDialog<FmWord, FmWordViewModel>();
            containerRegistry.RegisterDialog<FmPrint, FmPrintViewModel>();
        }
    }
}